<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class ServicePackChannel_Model extends CI_Model{
	protected $_name = "service_pack_channel";
	var $SpId = "SpId", $ChannelId = "ChannelId";
	
	function deleteSPCByChannelId($ChannelId){
		$this->db->where($this->ChannelId, $ChannelId);
		$this->db->delete($this->_name);
	}
	
	function deleteSPCBySpId($SpId){
		$this->db->where($this->SpId, $SpId);
		$this->db->delete($this->_name);
	}
	
	function insertServicePackChannel($SpId, $ChannelId){
		if($this->getExistServicePackChannel($SpId, $ChannelId) == 0){
			$this->db->set($this->SpId, $SpId);
			$this->db->set($this->ChannelId, $ChannelId);
			$this->db->insert($this->_name);
		}
	}
	
	function getExistServicePackChannel($SpId, $ChannelId){
		$this->db->where($this->SpId, $SpId);
		$this->db->where($this->ChannelId, $ChannelId);
		$query = $this->db->get($this->_name);
		return $query->num_rows();
	}
	function getServicePackChannelBySpId($SpId){
		$this->db->where($this->SpId, $SpId);
		$query = $this->db->get($this->_name);
		return $query->result();
	}
}